package com.kgc.service.impl;

import com.kgc.entity.Student;
import com.kgc.dao.StudentDao;
import com.kgc.service.StudentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 学生表(Student)表服务实现类
 *
 * @author unicorn
 * @since 2020-05-21 13:34:22
 */
@Service("studentService")
public class StudentServiceImpl implements StudentService {
    @Resource
    private StudentDao studentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Student queryById(Integer id) {
        return this.studentDao.queryById(id);
    }

    @Override
    public String login(Student student) {
        Student loginStudent = this.studentDao.login(student);
        if(loginStudent!=null){
            return "success";
        }
        return "error";
    }


    /**
     * 新增数据
     *
     * @param student 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(Student student) {
       return this.studentDao.insert(student);
    }

    /**
     * 修改数据
     *
     * @param student 实例对象
     * @return 实例对象
     */
    @Override
    public Integer update(Student student) {
        return this.studentDao.update(student);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public Integer deleteById(Integer id) {
        return this.studentDao.deleteById(id);
    }
}